package org.wmq.skycommon.aspect;

import org.aopalliance.intercept.Joinpoint;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import org.wmq.skycommon.context.BaseContext;

import java.time.LocalDateTime;

@Aspect
@Component
public class AutoFillAspect {

    @Pointcut("execution(* org.wmq.skyserver.mapper.*.*(..)) && @annotation(org.wmq.skycommon.annotation.AutoFill)")
    public void AutoFillPointCut(){}

    @Before("AutoFillPointCut()")
    public void autoFill(JoinPoint joinpoint){
        //获取到当前被拦截的方法上的数据库操作类型
        joinpoint.getSignature();
        //获取到当前被拦截的参数（实体对象）
        LocalDateTime now = LocalDateTime.now();
        Long id = BaseContext.getCurrentId();
        //准备赋值的数据
    }
}
